package com.itcast.order.service.impl;

import com.itcast.order.dao.OrderMapper;
import com.itcast.order.pojo.Order;
import com.itcast.order.service.OrderService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;


    @Override
    public List<Order> findListByUsername(String username) {
        if (StringUtils.isBlank(username)){
            return null;
        }
        Example example = new Example(Order.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("username",username);
        List<Order> orders = orderMapper.selectByExample(example);
        return orders;
    }
}
